<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<META name="generator" content="HTML Tidy for Linux/x86 (vers 12 April 2005), see www.w3.org">
<TITLE>Regular Expressions</TITLE>
<META name="GENERATOR" content="Modular DocBook HTML Stylesheet Version 1.79">
<LINK rel="HOME" title="Abyss Web Server For Windows User's Guide" href="index.html">
<LINK rel="PREVIOUS" title="Patterns Format" href="patternsformat.html">
<LINK rel="NEXT" title="Uninstalling The Software" href="uninstall.html">
<LINK rel="STYLESHEET" type="text/css" href="stylesheet.css">
<META name="AppleIcon" content="icon.png">
<META name="AppleTitle" content="Abyss Web Server Help">
</HEAD>
<BODY class="APPENDIX" bgcolor="#FFFFFF" text="#000000">
<DIV class="NAVHEADER">
<TABLE summary="Header navigation table" width="100%" border="0" cellpadding="0" cellspacing="0">
<TR>
<TH colspan="3" align="center">Abyss Web Server For Windows User's Guide</TH>
</TR>
<TR>
<TD width="10%" align="left" valign="bottom"><A href="patternsformat.html" accesskey="P">Prev</A></TD>
<TD width="80%" align="center" valign="bottom"></TD>
<TD width="10%" align="right" valign="bottom"><A href="uninstall.html" accesskey="N">Next</A></TD>
</TR>
</TABLE>
<HR align="left" width="100%"></DIV>
<DIV class="APPENDIX">
<H1><A name="REGEX" id="REGEX"></A>Appendix E. Regular Expressions</H1>
<P>Regular expressions in Abyss Web Server conform to the PCRE syntax (Perl Compatible Regular Expressions). This appendix is a quick guide to understand the basics of regular expressions. For an extensive description of their syntax, refer to the PCREPATTERN section in <KBD class="USERINPUT"><A href="http://pcre.org/pcre.txt" target="_top">http://pcre.org/pcre.txt</A></KBD>.</P>
<P>When matching a string (a sequence of characters) with a regular expression, the following rules apply:</P>
<UL>
<LI>
<P><KBD class="USERINPUT">.</KBD> matches any character,</P>
</LI>
<LI>
<P><KBD class="USERINPUT">*</KBD> repeats the previous match zero or more times,</P>
</LI>
<LI>
<P><KBD class="USERINPUT">+</KBD> repeats the previous match one or more times,</P>
</LI>
<LI>
<P><KBD class="USERINPUT">?</KBD> repeats the previous match zero or one time at most,</P>
</LI>
<LI>
<P><KBD class="USERINPUT">{</KBD>n<KBD class="USERINPUT">,</KBD>m<KBD class="USERINPUT">}</KBD> repeats the previous match n times at least and m times at most (n and m are positive integers),</P>
</LI>
<LI>
<P><KBD class="USERINPUT">{</KBD>n<KBD class="USERINPUT">}</KBD> repeats the previous match exactly n times,</P>
</LI>
<LI>
<P><KBD class="USERINPUT">{</KBD>n<KBD class="USERINPUT">,}</KBD> repeats the previous match n times at least,</P>
</LI>
<LI>
<P><KBD class="USERINPUT">{,</KBD>m<KBD class="USERINPUT">}</KBD> repeats the previous match m times at most,</P>
</LI>
<LI>
<P><KBD class="USERINPUT">^</KBD> is an anchor which matches with the beginning of a string,</P>
</LI>
<LI>
<P><KBD class="USERINPUT">$</KBD> is an anchor which matches with the end of a string,</P>
</LI>
<LI>
<P><KBD class="USERINPUT">[</KBD>set<KBD class="USERINPUT">]</KBD> matches any character in the specified set,</P>
</LI>
<LI>
<P><KBD class="USERINPUT">[^</KBD>set<KBD class="USERINPUT">]</KBD> matches any character not in the specified set,</P>
</LI>
<LI>
<P><KBD class="USERINPUT">\</KBD> suppresses the syntactic significance of a special character,</P>
</LI>
<LI>
<P><KBD class="USERINPUT">(</KBD>expression<KBD class="USERINPUT">)</KBD> groups the characters between the parentheses into a single unit and captures a match for later use as a backreference (<KBD class="USERINPUT">$1</KBD>, ... , <KBD class="USERINPUT">$9</KBD>).</P>
</LI>
</UL>
<P>A set is made of characters or ranges. A range is formed by two characters with a <KBD class="USERINPUT">-</KBD> in the middle (as in <KBD class="USERINPUT">0-9</KBD> or <KBD class="USERINPUT">a-z</KBD>).</P>
<P>Preceding a special character with <KBD class="USERINPUT">\</KBD> makes it loose its syntactic significance and match that character exactly. Outside a set, the special characters are <KBD class="USERINPUT">()[]{}.*+?^$\</KBD>. Inside a set, the special characters are <KBD class="USERINPUT">[]\-^</KBD>.</P>
<DIV class="EXAMPLE"><A name="AEN3109" id="AEN3109"></A>
<P><B>Example E-1. Examples of Regular Expressions</B></P>
<UL>
<LI>
<P><KBD class="USERINPUT">abc</KBD>: any string containing the substring <KBD class="USERINPUT">abc</KBD> matches with this regular expression.</P>
</LI>
<LI>
<P><KBD class="USERINPUT">abcd*</KBD>: any string containing the substring <KBD class="USERINPUT">abc</KBD> followed by zero or more <KBD class="USERINPUT">d</KBD> characters matches with this regular expression.</P>
</LI>
<LI>
<P><KBD class="USERINPUT">abcd?</KBD>: any string containing the substring <KBD class="USERINPUT">abc</KBD> or <KBD class="USERINPUT">abcd</KBD> matches with this regular expression.</P>
</LI>
<LI>
<P><KBD class="USERINPUT">ab(cd)?</KBD>: any string containing the substring <KBD class="USERINPUT">ab</KBD> or <KBD class="USERINPUT">abcd</KBD> matches with this regular expression.</P>
</LI>
<LI>
<P><KBD class="USERINPUT">^/dir</KBD>: any string starting with the substring <KBD class="USERINPUT">/dir</KBD> matches with this regular expression.</P>
</LI>
<LI>
<P><KBD class="USERINPUT">\.exe$</KBD>: any string ending with the substring <KBD class="USERINPUT">.exe</KBD> matches with this regular expression. Note here that the character <KBD class="USERINPUT">.</KBD> has been escaped to remove its special meaning.</P>
</LI>
<LI>
<P><KBD class="USERINPUT">^/dir/.*\.exe$</KBD>: any string beginning with <KBD class="USERINPUT">/dir</KBD> and ending with <KBD class="USERINPUT">.exe</KBD> matches with this regular expression.</P>
</LI>
<LI>
<P><KBD class="USERINPUT">^/dir/[^./]+\.exe$</KBD>: any string starting with <KBD class="USERINPUT">/dir</KBD> followed by 1 or more characters except <KBD class="USERINPUT">.</KBD> and <KBD class="USERINPUT">/</KBD>, and followed by <KBD class="USERINPUT">.exe</KBD> matches with this regular expression.</P>
</LI>
</UL>
</DIV>
<DIV class="EXAMPLE"><A name="AEN3153" id="AEN3153"></A>
<P><B>Example E-2. Examples of Backreferences</B></P>
<UL>
<LI>
<P><KBD class="USERINPUT">/dir/test.exe</KBD> matches with <KBD class="USERINPUT">^/dir/([^./]+)\.exe$</KBD>. This regular expression has a single group <KBD class="USERINPUT">([^./]+)</KBD> which defines the backreference <KBD class="USERINPUT">$1</KBD>. In this case, <KBD class="USERINPUT">$1</KBD>'s value is <KBD class="USERINPUT">test</KBD>.</P>
</LI>
<LI>
<P><KBD class="USERINPUT">/dir/test.exec</KBD> matches with <KBD class="USERINPUT">/dir/([^./]+)\.(exe.*)$</KBD>. This regular expression has two groups: <KBD class="USERINPUT">([^./]+)</KBD> which defines the backreference <KBD class="USERINPUT">$1</KBD>, and <KBD class="USERINPUT">(exe.*)</KBD> which defines the backreference <KBD class="USERINPUT">$2</KBD>. In this case, <KBD class="USERINPUT">$1</KBD>'s value is <KBD class="USERINPUT">test</KBD> and <KBD class="USERINPUT">$2</KBD>'s value is <KBD class="USERINPUT">exec</KBD>.</P>
</LI>
</UL>
</DIV>
</DIV>
<DIV class="NAVFOOTER">
<HR align="left" width="100%">
<TABLE summary="Footer navigation table" width="100%" border="0" cellpadding="0" cellspacing="0">
<TR>
<TD width="33%" align="left" valign="top"><A href="patternsformat.html" accesskey="P">Prev</A></TD>
<TD width="34%" align="center" valign="top"><A href="index.html" accesskey="H">Home</A></TD>
<TD width="33%" align="right" valign="top"><A href="uninstall.html" accesskey="N">Next</A></TD>
</TR>
<TR>
<TD width="33%" align="left" valign="top">Patterns Format</TD>
<TD width="34%" align="center" valign="top">&nbsp;</TD>
<TD width="33%" align="right" valign="top">Uninstalling The Software</TD>
</TR>
</TABLE>
</DIV>
<DIV class="COPYRIGHT">Copyright &copy; 2001-2009 Aprelium</DIV>
</BODY>
</HTML>
